<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <base href="<%=basePath%>">
    <meta charset="utf-8"/>
    <title>广告配置</title>
    <meta name="description" content="overview & stats"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <link href="static/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="static/css/bootstrap-responsive.min.css" rel="stylesheet"/>
    <link rel="stylesheet" href="static/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="static/css/ace.min.css"/>
    <link rel="stylesheet" href="static/css/ace-responsive.min.css"/>
    <link rel="stylesheet" href="static/css/ace-skins.min.css"/>
    <script type="text/javascript" src="static/js/jquery-1.7.2.js"></script>
    <!--提示框-->
    <script type="text/javascript" src="static/js/jquery.tips.js"></script>
    <style>
        .shijianinput input {
            width: 200px;
            margin-left: 50px;
            float: left;
        }

        #buliangcon {
            width: 200px;
            float: left;
        }
    </style>
</head>

<script type="text/javascript">
    $(function () {
        top.hangge();

        $("#adStartFun").change(function () {
            var value = $(this).children('option:selected').val();
            if (value == "adFillDic") {
                $("#buliangcon").css("display", "block");
            } else {
                $("#buliangcon").css("display", "none");
            }
        })

    });

    function save() {
        $("#menuForm").submit();
        $("#zhongxin").hide();
        $("#zhongxin2").show();
    }

</script>

<body>
<form action="adversters/config" name="menuForm" id="menuForm" method="post" enctype="multipart/form-data">
    <div id="zhongxin" class="zhongxin-cla">
        <table>
            <tr>
                <td>
                    <span>APP开屏广告：</span>
                    <select class="input_txt" name="appOpenAdvertSwitch" id="appOpenAdvertSwitch"
                            style="vertical-align:top;width: 150px;">
                        <option value="1"
                                <c:if test="${config.adverstersComInfo.appOpenAdvertSwitch == 1}">selected</c:if>>开启
                        </option>
                        <option value="0"
                                <c:if test="${config.adverstersComInfo.appOpenAdvertSwitch == 0}">selected</c:if>>关闭
                        </option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>
                    <span style="float: left">广告开启方式：</span>
                    <select class="input_txt" name="adStartFun" id="adStartFun"
                            style="vertical-align:top;width: 150px;float: left">
                        <option value="adList"
                                <c:if test="${config.adverstersComInfo.adStartFun == 'adList'}">selected</c:if>>时间段
                        </option>
                        <option value="adListWeight"
                                <c:if test="${config.adverstersComInfo.adStartFun == 'adListWeight'}">selected</c:if>>权重
                        </option>
                        <option value="adFillDic"
                                <c:if test="${config.adverstersComInfo.adStartFun == 'adFillDic'}">selected</c:if>>补量
                        </option>
                    </select>
                    <span id="buliangcon"
                          <c:if test="${config.adverstersComInfo.adStartFun != 'adFillDic'}">style="display: none"</c:if>>
							补量：优先第1个补量第2个
						</span>
                </td>
            </tr>
            <tr>
                <td>
                    <span>加载失败时启用：</span>
                    <select class="input_txt" name="adFailUserADName" id="adFailUserADName"
                            style="vertical-align:top;width: 150px;">
                        <c:forEach items="${config.adversters}" var="adverster">
                            <option value="${adverster.shortName}"
                                    <c:if test="${config.adverstersComInfo.adFailUserADName == adverster.shortName}">selected</c:if>>
                                    ${adverster.shortName}
                            </option>
                        </c:forEach>
                    </select>
                </td>
            </tr>
            <tr>
                <td>
                    <span>无广告账号：</span>
                    <input type="text" name="appAuditAccount" id="appAuditAccount"
                           value="${config.adverstersComInfo.appAuditAccount}" placeholder="用于APP上架审核，填入账号openid"/>
                </td>
            </tr>
            <tr>
                <td>
                    <span>无广告版本号：</span>
                    <input type="text" name="internalADFreeVersion" id="internalADFreeVersion"
                           value="${config.adverstersComInfo.internalADFreeVersion}"
                           placeholder="用于APP上架审核，填入账号openid"/>
                </td>
            </tr>
            <tr>
                <td>
                    <span>API口令链接：</span>
                    <input type="text" name="apiWordLink" id="apiWordLink"
                           value="${config.adverstersComInfo.apiWordLink}" placeholder="API口令链接,获取链接的data.text"/>
                </td>
            </tr>
            <tr>
                <td>
                    <span>APP内部广告：</span>
                    <select class="input_txt" name="appInternalADswitch" id="appInternalADswitch"
                            style="vertical-align:top;width: 150px;">
                        <option value="1"
                                <c:if test="${config.adverstersComInfo.appInternalADswitch == '1'}">selected</c:if>>开启
                        </option>
                        <option value="0"
                                <c:if test="${config.adverstersComInfo.appInternalADswitch == '0'}">selected</c:if>>关闭
                        </option>
                    </select>
                </td>
            </tr>
            <c:forEach items="${config.data}" var="data">
                <tr style="height: 220px">
                    <td>
                        <div style="">
                            <span>${data.name.value}(优先级：${data.index})：</span>
                            <select class="input_txt" name="${data.status.name}" style="vertical-align:top;width: 20%">
                                <option value="1" <c:if test="${data.status.value == 1}">selected</c:if>>开启</option>
                                <option value="0" <c:if test="${data.status.value == 0}">selected</c:if>>关闭</option>
                            </select>

                            <font color='red'>*</font>
                            <span>权重(总和为1)：</span>
                            <input type="number" name="${data.ADweight.name}" value="${data.ADweight.value}"
                                   style="width: 30%"/>
                        </div>
                        <span class="shijianinput">
								<input type="text" value="${data.start_time1.value}" name="${data.start_time1.name}"
                                       placeholder="00:00~24:00(格式:00:00)">
								<input type="text" value="${data.end_time1.value}" name="${data.end_time1.name}"
                                       placeholder="00:00~24:00(格式:00:00)">
							</span>
                        <span class="shijianinput">
								<input type="text" value="${data.start_time2.value}" name="${data.start_time2.name}"
                                       placeholder="00:00~24:00(格式:00:00)">
								<input type="text" value="${data.end_time2.value}" name="${data.end_time2.name}"
                                       placeholder="00:00~24:00(格式:00:00)">
							</span>
                        <span class="shijianinput">
								<input type="text" value="${data.start_time3.value}" name="${data.start_time3.name}"
                                       placeholder="00:00~24:00(格式:00:00)">
								<input type="text" value="${data.end_time3.value}" name="${data.end_time3.name}"
                                       placeholder="00:00~24:00(格式:00:00)">
							</span>
                    </td>
                </tr>
            </c:forEach>
            <tr>
                <td style="text-align: center; padding-top: 10px;">
                    <a class="btn btn-mini btn-primary" onclick="save();">保存</a>
                    <a class="btn btn-mini btn-danger" onclick="top.Dialog.close();">取消</a>
                </td>
            </tr>
        </table>
    </div>
    <div id="zhongxin2" class="center" style="display:none">
        <br/><br/><br/><img src="static/images/jiazai.gif"/><br/>
        <h4 class="lighter block green"></h4>
    </div>
</form>
</body>
</html>